//
//  PlacardCell.m
//  CBT
//
//  Created by Mr.Zhang on 2018/11/24.
//  Copyright © 2018 Mr.Zhang. All rights reserved.
//

#import "PlacardCell.h"

@interface PlacardCell()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *detailLabelHeiCon;
@property (weak, nonatomic) IBOutlet UIButton *showDetailBtn;
@property (weak, nonatomic) IBOutlet UIButton *showDetailImageBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rootViewHeiCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roundImageViewHeiCon;
@property (weak, nonatomic) IBOutlet UIImageView *roundImageView;



@end

@implementation PlacardCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.roundImageView.image = [UIImage resizableImageWithName:@"huijiao"];
    
}

- (IBAction)showAllMsgAction:(UIButton *)sender {
    if (self.PlacardCellBlock != nil) {
        self.PlacardCellBlock(self.indexRow,self.model.isOpen);
    }
}


-(void)setModel:(MainNewsItemModel *)model
{
    _model = model;
    _titleLabel.text  = model.title;
    _detailLabel.text = model.content;
    _timeLabel.text   = [NSString getCBTShowDateNoYestodayWithTime:[model.createDate longLongValue]];
    [_showDetailBtn setTitle:kLocalizedString(@"查看全文", nil) forState:(UIControlStateNormal)];
    [_showDetailImageBtn setImage:[UIImage imageNamed:model.isOpen ? @"gonggaoxiangqing_shangla" : @"gonggaoxiangqing_xiala"] forState:(UIControlStateNormal)];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.timeLabel.textAlignment = self.model.isTopCell ?  NSTextAlignmentRight : NSTextAlignmentLeft;
    self.showDetailBtn.hidden    = self.model.isTopCell;
    self.detailLabelHeiCon.constant = self.model.detailLabelHeight;
    self.showDetailImageBtn.hidden  = self.model.isTopCell;
    self.rootViewHeiCon.constant    = self.model.rootViewHeight;
    self.roundImageViewHeiCon.constant = self.model.rootViewHeight;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
